package com.panghl.test01.service;


import com.panghl.entity.User;
import com.panghl.test01.mapper.UserMapper01;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * transactionManager: 指定事务管理器---> 解决以下错误
 * nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException:
 * No qualifying bean of type 'org.springframework.transaction.TransactionManager'
 * available: expected single matching bean but found 2:
 * test01DataSourceTransactionManager,test02DataSourceTransactionManager
 */
@Service
@Transactional(transactionManager = "test01DataSourceTransactionManager")
public class UserService01 {
    @Resource
    private UserMapper01 userMapper01;

    public User findByName(String name){
        return userMapper01.findByName(name);
    }

    public int insert(String username,String password,Integer age){
        int insert = userMapper01.insert(username, password);
        int i = 1/age;
        return insert;
    }

}
